<?php

function noAdmin()
{
	return '404 not found.';
}
function displayCS()
{
	include_once('./app/directoryLib.php');

	if(get('del') != 'null')
	{
		delAcct(get('del'));
	}
	//VARS
	$options = listAccounts(get('type'));;
	
	$buttonText = (get('type') == 'general' ? '' : ucwords(get('type')));
	
	$entry = getInitItem(get('entry'), get('type'));
	
	//DATABASE
	$companyName = getThisAccount($entry, '_name');
	
	$address = getThisAccount($entry, '_address');
	
	$notes = getThisAccount($entry, '_notes');;
	
	$cDetails = getAccountDetails($entry);
	
	$status = getAccountStats($entry);
	
	$dateCreated = $status['created'];
	$dateUpdated = $status['updated'];
	$lastUser = $status['updatedBy'];
	
	$accountType = 'Supplier/Client/General';
	$type = (get('type') == 'general' ? '<h2>'.$accountType.' Account</h2>' : '');
	//PAGE
	$disVar = '
	<div id="accountpage"></div>
	<div class="grid_12 mainBox bordered">
		<h1>'.ucwords(get('type')).' Directory</h1>	
	</div>
	<div class="clear">
	<!--spanner-->
	</div>
	<div class="grid_12 mainBox bordered topRight">
		<div class="grid_4 alpha">
			<h3>'.ucwords(get('type')).' List</h3>
			<select name="list" class="globalSelector" size="6">
				'.$options.'
			</select>	
		</div>
		<div class="grid_8 omega">
			<h3>Help:</h3>
			<p>To search for a '.strtolower(get('type')).' account, simply refer to the list on the left. Use the scrollbar to scroll through the different '.strtolower(get('type')).' accounts. Click on your desired account and wait for the page to reload. </p><p>To add a new '.$buttonText.' account, click on the \'Create '.$buttonText.' Account\' button and fill up the necessary details. To edit or delete a specific account, click on the \'Modify '.$buttonText.' Account\' button. If you experience any technical difficulties, do not hesitate to send us an inquiry through our website.</p>
			<p class="rightAlign logoCreds">
				- '.logo().'
			</p>
		</div>
	</div>
	<div class="clear">
	<!--spanner-->
	</div>
	<div class="grid_12 mainBox topRight">
		<div class="grid_12 alpha">
			<h4>'.$companyName.'</h4>
			'.$type.'
			<p class="address">'.$address.'</p>
			<p class="notes">'.$notes.'</p>
		</div>
	</div>
	<div class="clear">
	<!--spanner-->
	</div>
	<div class="grid_12 mainBox bordered">
		<div class="grid_8 alpha contactHeader borderbottom">
			<h3>'.$buttonText.' Contact Details</h3>
		</div>
		<div class="grid_4 omega contactHeader borderbottom">
			<h3>'.$buttonText.' Account Status</h3>
		</div>
		<div class="clear">
		<!--spanner-->
		</div>
		<div class="grid_4 alpha">
			<div class="grid_2 alpha bold">
				'.$cDetails[0][0].'
			</div>
			<div class="grid_2 omega">
				'.$cDetails[0][1].'
			</div>
		</div>
		<div class="grid_4">
			<div class="grid_2 alpha bold">
				'.$cDetails[1][0].'
			</div>
			<div class="grid_2 omega">
				'.$cDetails[1][1].'
			</div>
		</div>
		<div class="grid_4 omega">
			<div class="grid_2 alpha bold">
				Created:<br />Updated:<br />Last Accessed:
			</div>
			<div class="grid_2 omega">
				'.$dateCreated.'<br />'.$dateUpdated.'<br />'.$lastUser.'
			</div>
		</div>
	</div>
	<div class="clear">
	<!--spanner-->
	</div>
	<div class="grid_12 mainBox centerAlign">
		<input type="button" id="'.$buttonText.'CButton" value="Create New '.$buttonText.' Account" class="buttons"/>
		'.(get('entry') == 'null' ? '' : '<input type="button" id="'.$buttonText.'MButton" value="Modify This '.$buttonText.' Account" class="buttons" rel="'.$entry.'"/>').'
	</div>
	';
	return $disVar;
}
function displayPage()
{
	$output = adminContent((get('type') == 'client' || get('type') == 'supplier' || get('type') == 'general' ? displayCS() : noAdmin()),noAdmin());
	return $output;
}
?>